//
//  APMeItemControl.m
//  AqualPolo
//
//  Created by dong on 2024/5/7.
//

#import "APMeItemControl.h"

@implementation APMeItemControl

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.layer.cornerRadius = 8;
        self.layer.masksToBounds = true;
        [self setGradientBackgroundWithColors:@[LYRGBColor(45, 116, 255),LYRGBAColor(80, 216, 216, 0.2)] locations:@[@0,@1] startPoint:CGPointMake(0.5, 0) endPoint:CGPointMake(0.5, 1)];
        UIView *contentView = [[UIView alloc] init];
        contentView.userInteractionEnabled = false;
        contentView.layer.cornerRadius = 8;
        contentView.layer.masksToBounds = true;
        [self addSubview:contentView];
        [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self).insets(UIEdgeInsetsMake(1, 1, 1, 1));
        }];
        [contentView setGradientBackgroundWithColors:@[LYRGBColor(24, 56, 92),LYRGBColor(6, 52, 75)] locations:@[@0,@1] startPoint:CGPointMake(0.5, 0) endPoint:CGPointMake(0.5, 1)];
        
        _imageView = [[UIImageView alloc] init];
        [contentView addSubview:_imageView];
        [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(16);
            make.size.mas_equalTo(CGSizeMake(38, 37));
            make.centerX.equalTo(self);
        }];
        
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = [UIColor whiteColor];
        _titleLabel.font = [LYFont fontWithSize:16 fontName:LYFontNamepfr];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        [contentView addSubview:_titleLabel];
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(contentView.mas_bottom).offset(-8);
            make.left.right.equalTo(contentView);
        }];
        
    }
    return self;
}

@end
